import flash.display.DisplayObject;
import flash.events.Event;

import mx.controls.Alert;
import mx.core.FlexGlobals;
import mx.events.CloseEvent;
import mx.events.FlexEvent;
import mx.rpc.events.ResultEvent;
import mx.styles.IStyleManager;
import mx.styles.IStyleManager2;
import mx.styles.StyleManager;

[Bindable]  
private var xml:XML;
private var themeSum:int;
private var thmemCount:int = 0;
private var _skip:String;

protected function initData(event:FlexEvent):void {
	themeHttp.send();
}

protected function themeHttp_resultHandler(event:ResultEvent):void
{
	xml = new XML(event.result);
	themeSum = xml.theme.length();
	change_thmem();
}

protected function change_thmem():void {
	if(_skip != null){
		StyleManager.unloadStyleDeclarations(_skip , true);
	}
	_skip = String((xml.theme)[thmemCount].@skip);
	StyleManager.loadStyleDeclarations(_skip , true);
	thmemCount++;
	if(thmemCount >= themeSum){
		thmemCount = 0;
	}
}

private function exit():void {
	Alert.show("确定退出吗？","温馨提示" , Alert.YES|Alert.NO , FlexGlobals.topLevelApplication.vk , confirmExit);
}

protected function confirmExit(event:CloseEvent):void {
	if(event.detail == Alert.YES){
		FlexGlobals.topLevelApplication.vk.selectedIndex = 0;
	}
}
